class Node:
    def __init__(self,value):
        self._value = value
        self._chidlren =[]

    def __repr__(self):
        return 'Node({!r})'.format(self._value)

    def add_child(self,node):
        self._chidlren.append(node)

    def __iter__(self):
        return iter(self._chidlren)

if __name__ == '__main__':
    root = Node(0)
    child1 = Node(1)
    child2 = Node(2)
    root.add_child(child1)
    root.add_child(child2)
    for ch in root: # 当作为被迭代对象的时候，使用__iter__方法
        print(ch)